
******************
**** Analysis ****
******************

** set working dir

cd XXXX
set more off

use data.dta

**	 	There are total of 165 subjects in the experiment
**
** 		The experiment consists of 10 questions and a bunch of controls:
**
**				main questions 
**                  (*) four MPL (q1, q2, q3, and q4) which we use for risk and Allais
**					(*) three MPL (q5, q6, q7)
**					(*) three Ranges (q5r, q6r, q7r)
**
** 				controls
**					(*)	two risk investment questions (risk1, risk2)
** 					(*) IQ questions (Raven matrices, rotations, CRT)
**					(*) overprecision and overconfidence
**
**		The main sample for the analysis includes people who do not choose DOMINATED options in the 10 main questions


***************************************
**   MERGE DATASET WITH CHAT ANSWERS **
***************************************

merge 1:1 responseid using "/why.dta", force
save datachat.dta, replace



**************************
****   Main Sample    ****
**************************

gen mainsample =(q1_dom!=1 & q2_dom!=1 & q3_dom!=1 & q4_dom!=1 & q5_dominated!=1 & q6_dominated!=1 & q7_dominated!=1 & q5r_dominated!=1 & q6r_dominated!=1 & q7r_dominated!=1)
tab mainsample

** There are 148 subjects in the main sample (out of 165 total)


** Indicators of having range91 or range64
**		q5r_91_norange,  q6r_91_norange,  q7r_91_norange
**		q5r_64_norange,  q6r_64_norange,  q7r_64_norange

** How many questions with Ranges a subject reports?
gen range91Three = (q5r_91_norange==0 & q6r_91_norange==0 & q7r_91_norange==0)
gen range91Two   = ((q5r_91_norange==0 & q6r_91_norange==0) | (q5r_91_norange==0 & q7r_91_norange==0) | (q6r_91_norange==0 & q7r_91_norange==0))
gen range91One   = (q5r_91_norange==0 | q6r_91_norange==0 | q7r_91_norange==0)
 
gen range64Three = (q5r_64_norange==0 & q6r_64_norange==0 & q7r_64_norange==0 )
gen range64Two   = ((q5r_64_norange==0 & q6r_64_norange==0) | (q5r_64_norange==0 & q7r_64_norange==0) | (q6r_64_norange==0 & q7r_64_norange==0)) 
gen range64One   = (q5r_64_norange==0 | q6r_64_norange==0 | q7r_64_norange==0) 

gen     range91NumQ = 0 if range91One==0
replace range91NumQ = 1 if range91One==1
replace range91NumQ = 2 if range91Two==1
replace range91NumQ = 3 if range91Three==1
 
gen     range64NumQ = 0 if range64One==0
replace range64NumQ = 1 if range64One==1
replace range64NumQ = 2 if range64Two==1
replace range64NumQ = 3 if range64Three==1

tab range91NumQ if mainsample==1 
tab range64NumQ if mainsample==1

** Indicator that a subject does not report ranges in any of the three main questions
gen noranges91 = (range91NumQ==0) 
gen noranges64 = (range64NumQ==0)

tab noranges91 if mainsample==1 
tab noranges64 if mainsample==1
 
** Range Size 
 
gen q5r_range91_size = q5r_range91_max_DollAv - q5r_range91_min_DollAv 
gen q6r_range91_size = q6r_range91_max_DollAv - q6r_range91_min_DollAv
gen q7r_range91_size = q7r_range91_max_DollAv - q7r_range91_min_DollAv

gen q5r_range64_size = q5r_range64_max_DollAv - q5r_range64_min_DollAv
gen q6r_range64_size = q6r_range64_max_DollAv - q6r_range64_min_DollAv
gen q7r_range64_size = q7r_range64_max_DollAv - q7r_range64_min_DollAv

replace q5r_range91_size = 0  if q5r_91_norange==1
replace q6r_range91_size = 0  if q6r_91_norange==1
replace q7r_range91_size = 0  if q7r_91_norange==1

replace q5r_range64_size = 0  if q5r_64_norange==1
replace q6r_range64_size = 0  if q6r_64_norange==1
replace q7r_range64_size = 0  if q7r_64_norange==1


** Number of rows
gen q5r_range91_numrows = q5r_91max - q5r_91min
gen q5r_range64_numrows = q5r_64max - q5r_64min
gen q6r_range91_numrows = q6r_91max - q6r_91min
gen q6r_range64_numrows = q6r_64max - q6r_64min
gen q7r_range91_numrows = q7r_91max - q7r_91min
gen q7r_range64_numrows = q7r_64max - q7r_64min

** THERE ARE SOME PEOPLE THAT HAVE NO q7r_rangeXX_max_DollAv becaues they ALWAYS choose the right option in all rows
** clearly, they do not have ranges, so we will set size of range to be zero for them

replace q7r_range91_size = 0  if q7r_range91_max_DollAv==. 
replace q7r_range64_size = 0  if q7r_range64_max_DollAv==.

sum q5r_range91_size if mainsample==1
sum q6r_range91_size if mainsample==1
sum q7r_range91_size if mainsample==1

sum q5r_range64_size if mainsample==1
sum q6r_range64_size if mainsample==1
sum q7r_range64_size if mainsample==1

** Normalized range size in all three questions - normalized by the max range size allowed in the experiment

gen range91size_norm1 = (q5r_range91_size / 20 +  q6r_range91_size / 36 + q7r_range91_size / 8)/3 
gen range64size_norm1 = (q5r_range64_size / 20 +  q6r_range64_size / 36 + q7r_range64_size / 8)/3

** Normalized range size in all three questions - normalized by the expected value of the left option

gen range91size_norm2 = (q5r_range91_size / 10 +  q6r_range91_size / 18 + q7r_range91_size / 11)/3 
gen range64size_norm2 = (q5r_range64_size / 10 +  q6r_range64_size / 18 + q7r_range64_size / 11)/3

sum range91size_norm1 range91size_norm2 range64size_norm1 range64size_norm2 



**************************
*****   Q-measures     ***
**************************

** q-measure for Q5R
forval i = 1(1)19{
gen tempq5r_`i' = 0
}

forval i = 2(1)18 {
replace tempq5r_`i' = choiceq5r`i'/10 if choiceq5r`i'<=5
replace tempq5r_`i' = 1 - choiceq5r`i'/10 if choiceq5r`i'>5
}

vioplot tempq5r_* if q5r_91_norange==0
sum tempq5r_*     if q5r_91_norange==0

gen tempq5r_total= tempq5r_1+tempq5r_2+tempq5r_3+tempq5r_4+tempq5r_5+tempq5r_6+tempq5r_7+tempq5r_8+tempq5r_9+tempq5r_10+tempq5r_11+tempq5r_12+tempq5r_13+tempq5r_14+tempq5r_15+tempq5r_16+tempq5r_17+tempq5r_18+tempq5r_19    
gen tempq5r = tempq5r_total *2/17


** q-measure for Q6R
forval i = 1(1)23{
gen tempq6r_`i' = 0
}

forval i = 2(1)23 {
replace tempq6r_`i' = choiceq6r`i'/10 if choiceq6r`i'<=5
replace tempq6r_`i' = 1 - choiceq6r`i'/10 if choiceq6r`i'>5
}

vioplot tempq6r_* if q6r_91_norange==0
sum tempq6r_*     if q6r_91_norange==0

gen tempq6r_total= tempq6r_1+tempq6r_2+tempq6r_3+tempq6r_4+tempq6r_5+tempq6r_6+tempq6r_7+tempq6r_8+tempq6r_9+tempq6r_10+tempq6r_11+tempq6r_12+tempq6r_13+tempq6r_14+tempq6r_15+tempq6r_16+tempq6r_17+tempq6r_18+tempq6r_19+tempq6r_20 +tempq6r_21 +tempq6r_22 +tempq6r_23    
gen tempq6r = tempq6r_total *2/22


** q-measure for Q7R
forval i = 1(1)17{
gen tempq7r_`i' = 0
}

forval i = 1(1)16 {
replace tempq7r_`i' = choiceq7r`i'/10 if choiceq7r`i'<=5
replace tempq7r_`i' = 1 - choiceq7r`i'/10 if choiceq7r`i'>5
}

vioplot tempq7r_* if q7r_91_norange==0
sum tempq7r_*     if q7r_91_norange==0

gen tempq7r_total= tempq7r_1+tempq7r_2+tempq7r_3+tempq7r_4+tempq7r_5+tempq7r_6+tempq7r_7+tempq7r_8+tempq7r_9+tempq7r_10+tempq7r_11+tempq7r_12+tempq7r_13+tempq7r_14+tempq7r_15+tempq7r_16+tempq7r_17
gen tempq7r = tempq7r_total *2/16

** average q-measure
gen q_average = (tempq5r + tempq6r + tempq7r)/3




************************************************
*** TABLE 2: SUMMARY STATISTICS ABOUT RANGES ***
************************************************

tab q5r_91_norange if mainsample==1
tab q6r_91_norange if mainsample==1
tab q7r_91_norange if mainsample==1

tab q5r_64_norange if mainsample==1
tab q6r_64_norange if mainsample==1
tab q7r_64_norange if mainsample==1

reg q5r_range91_size if mainsample==1 & q5r_range91_size!=0
reg q5r_range64_size if mainsample==1 & q5r_range64_size!=0

sum q5r_range91_size if mainsample==1 & q5r_range91_size!=0, detail
sum q5r_range64_size if mainsample==1 & q5r_range64_size!=0, detail

reg q6r_range91_size if mainsample==1 & q6r_range91_size!=0
reg q6r_range64_size if mainsample==1 & q6r_range64_size!=0

sum q6r_range91_size if mainsample==1 & q6r_range91_size!=0, detail
sum q6r_range64_size if mainsample==1 & q6r_range64_size!=0, detail

reg q7r_range91_size if mainsample==1 & q7r_range91_size!=0
reg q7r_range64_size if mainsample==1 & q7r_range64_size!=0

sum q7r_range91_size if mainsample==1 & q7r_range91_size!=0, detail
sum q7r_range64_size if mainsample==1 & q7r_range64_size!=0, detail

reg q5r_range91_max_DollAv if mainsample==1 & q5r_range91_size!=0
reg q5r_range91_min_DollAv if mainsample==1 & q5r_range91_size!=0

reg q5r_range64_max_DollAv if mainsample==1 & q5r_range64_size!=0
reg q5r_range64_min_DollAv if mainsample==1 & q5r_range64_size!=0

reg q6r_range91_max_DollAv if mainsample==1 & q6r_range91_size!=0
reg q6r_range91_min_DollAv if mainsample==1 & q6r_range91_size!=0

reg q6r_range64_max_DollAv if mainsample==1 & q6r_range64_size!=0
reg q6r_range64_min_DollAv if mainsample==1 & q6r_range64_size!=0

reg q7r_range91_max_DollAv if mainsample==1 & q7r_range91_size!=0
reg q7r_range91_min_DollAv if mainsample==1 & q7r_range91_size!=0

reg q7r_range64_max_DollAv if mainsample==1 & q7r_range64_size!=0
reg q7r_range64_min_DollAv if mainsample==1 & q7r_range64_size!=0

sum q5r_range91_max_DollAv if mainsample==1 & q5r_range91_size!=0, detail
sum q5r_range91_min_DollAv if mainsample==1 & q5r_range91_size!=0, detail

reg q5r_range91_numrows if mainsample==1 & q5r_range91_size!=0 
reg q5r_range64_numrows if mainsample==1 & q5r_range64_size!=0 

reg q6r_range91_numrows if mainsample==1 & q6r_range91_size!=0 
reg q6r_range64_numrows if mainsample==1 & q6r_range64_size!=0 

reg q7r_range91_numrows if mainsample==1 & q7r_range91_size!=0 
reg q7r_range64_numrows if mainsample==1 & q7r_range64_size!=0 


sum q5r_range91_numrows if mainsample==1 & q5r_range91_size!=0, detail
sum q5r_range64_numrows if mainsample==1 & q5r_range64_size!=0, detail

sum q6r_range91_numrows if mainsample==1 & q6r_range91_size!=0, detail
sum q6r_range64_numrows if mainsample==1 & q6r_range64_size!=0, detail

sum q7r_range91_numrows if mainsample==1 & q7r_range91_size!=0, detail
sum q7r_range64_numrows if mainsample==1 & q7r_range64_size!=0, detail


** q-measure statistics for Table 2

count if tempq5r!=0 & mainsample==1
count if tempq6r!=0 & mainsample==1
count if tempq7r!=0 & mainsample==1

sum tempq5r if mainsample==1 & tempq5r!=0, det
sum tempq6r if mainsample==1 & tempq6r!=0, det
sum tempq7r if mainsample==1 & tempq7r!=0, det

** ranges are frequent

tab noranges91 if mainsample==1
tab noranges64 if mainsample==1

tab range91NumQ if mainsample==1
tab range64NumQ if mainsample==1
 
** ranges extend to the risk-loving domains

count if q5r_range91_size!=0 & q5r_range91_max_DollAv>10 & mainsamp==1
count if q5r_range91_size!=0 & q5r_range91_max_DollAv!=. & mainsamp==1

count if q6r_range91_size!=0 & q6r_range91_min_DollAv<36 & mainsamp==1
count if q6r_range91_size!=0 & q6r_range91_min_DollAv!=. & mainsamp==1

count if q7r_range91_size!=0 & q7r_range91_max_DollAv>18 & mainsamp==1
count if q7r_range91_size!=0 & q7r_range91_max_DollAv!=. & mainsamp==1


** how many people report ALWAYS monotone ranges?

count if mainsample==1 & (q5r_91_norange==0 | q6r_91_norange==0 | q7r_91_norange==0)
count if mainsample==1 & q5r_91_norange==0 & q6r_91_norange==0 & q7r_91_norange==0 & q5r_nonMonotoneRange==0 & q6r_nonMonotoneRange==0 & q7r_nonMonotoneRange==0
count if mainsample==1 & q5r_91_norange==1 & q6r_91_norange==0 & q7r_91_norange==0 & q6r_nonMonotoneRange==0 & q7r_nonMonotoneRange==0
count if mainsample==1 & q5r_91_norange==0 & q6r_91_norange==1 & q7r_91_norange==0 & q5r_nonMonotoneRange==0 & q7r_nonMonotoneRange==0
count if mainsample==1 & q5r_91_norange==0 & q6r_91_norange==0 & q7r_91_norange==1 & q5r_nonMonotoneRange==0 & q6r_nonMonotoneRange==0 
count if mainsample==1 & q5r_91_norange==1 & q6r_91_norange==1 & q7r_91_norange==0 & q7r_nonMonotoneRange==0
count if mainsample==1 & q5r_91_norange==1 & q6r_91_norange==0 & q7r_91_norange==1 & q6r_nonMonotoneRange==0
count if mainsample==1 & q5r_91_norange==0 & q6r_91_norange==1 & q7r_91_norange==1 & q5r_nonMonotoneRange==0


tab q5r_nonMonotoneRange if mainsample==1 & q5r_91_norange==0  
tab q6r_nonMonotoneRange if mainsample==1 & q6r_91_norange==0  
tab q7r_nonMonotoneRange if mainsample==1 & q7r_91_norange==0  



** correlation between q-measures and ranges
pwcorr q5r_91_norange q5r_range91_size q5r_64_norange q5r_range64_size tempq5r if mainsample==1 , sig
pwcorr q6r_91_norange q6r_range91_size q6r_64_norange q6r_range64_size tempq6r if mainsample==1 , sig 
pwcorr q7r_91_norange q7r_range91_size q7r_64_norange q7r_range64_size tempq7r if mainsample==1 , sig 



**************************************************************
*** APPENDIX: SUMMARY STATISTICS ABOUT OTHER RANGES        ***
**************************************************************

gen range82Three = (q5r_82_norange==0 & q6r_82_norange==0 & q7r_82_norange==0)
gen range82Two   = ((q5r_82_norange==0 & q6r_82_norange==0) | (q5r_82_norange==0 & q7r_82_norange==0) | (q6r_82_norange==0 & q7r_82_norange==0))
gen range82One   = (q5r_82_norange==0 | q6r_82_norange==0 | q7r_82_norange==0)
 
gen range73Three = (q5r_73_norange==0 & q6r_73_norange==0 & q7r_73_norange==0)
gen range73Two   = ((q5r_73_norange==0 & q6r_73_norange==0) | (q5r_73_norange==0 & q7r_73_norange==0) | (q6r_73_norange==0 & q7r_73_norange==0))
gen range73One   = (q5r_73_norange==0 | q6r_73_norange==0 | q7r_73_norange==0)
 
gen range55Three = (q5r_55_norange==0 & q6r_55_norange==0 & q7r_55_norange==0 )
gen range55Two   = ((q5r_55_norange==0 & q6r_55_norange==0) | (q5r_55_norange==0 & q7r_55_norange==0) | (q6r_55_norange==0 & q7r_55_norange==0)) 
gen range55One   = (q5r_55_norange==0 | q6r_55_norange==0 | q7r_55_norange==0) 

gen     range82NumQ = 0 if range82One==0
replace range82NumQ = 1 if range82One==1
replace range82NumQ = 2 if range82Two==1
replace range82NumQ = 3 if range82Three==1

gen     range73NumQ = 0 if range73One==0
replace range73NumQ = 1 if range73One==1
replace range73NumQ = 2 if range73Two==1
replace range73NumQ = 3 if range73Three==1
 
gen     range55NumQ = 0 if range55One==0
replace range55NumQ = 1 if range55One==1
replace range55NumQ = 2 if range55Two==1
replace range55NumQ = 3 if range55Three==1

tab range82NumQ if mainsample==1 
tab range73NumQ if mainsample==1 
tab range55NumQ if mainsample==1

** Indicator that a subject does not report ranges in any of the three main questions
gen noranges82 = (range82NumQ==0) 
gen noranges73 = (range73NumQ==0) 
gen noranges55 = (range55NumQ==0)

tab noranges82 if mainsample==1 
tab noranges73 if mainsample==1
tab noranges55 if mainsample==1


** Range Size 
 
gen q5r_range82_size = q5r_range82_max_DollAv - q5r_range82_min_DollAv 
gen q6r_range82_size = q6r_range82_max_DollAv - q6r_range82_min_DollAv
gen q7r_range82_size = q7r_range82_max_DollAv - q7r_range82_min_DollAv

gen q5r_range73_size = q5r_range73_max_DollAv - q5r_range73_min_DollAv 
gen q6r_range73_size = q6r_range73_max_DollAv - q6r_range73_min_DollAv
gen q7r_range73_size = q7r_range73_max_DollAv - q7r_range73_min_DollAv

gen q5r_range55_size = q5r_range55_max_DollAv - q5r_range55_min_DollAv
gen q6r_range55_size = q6r_range55_max_DollAv - q6r_range55_min_DollAv
gen q7r_range55_size = q7r_range55_max_DollAv - q7r_range55_min_DollAv

** THERE ARE SOME PEOPLE THAT HAVE NO q7r_rangeXX_max_DollAv becaues they ALWAYS choose the right option in all rows
** clearly, they do not have ranges, so we will set size of range to be zero for them

replace q7r_range82_size = 0  if q7r_range82_max_DollAv==.
replace q7r_range73_size = 0  if q7r_range73_max_DollAv==.  
replace q7r_range55_size = 0  if q7r_range55_max_DollAv==.

** frequency of ranges

tab q5r_82_norange if mainsample==1
tab q6r_82_norange if mainsample==1
tab q7r_82_norange if mainsample==1

tab q5r_73_norange if mainsample==1
tab q6r_73_norange if mainsample==1
tab q7r_73_norange if mainsample==1

tab q5r_55_norange if mainsample==1
tab q6r_55_norange if mainsample==1
tab q7r_55_norange if mainsample==1

** range size

reg q5r_range82_size if mainsample==1 & q5r_82_norange==0
reg q5r_range73_size if mainsample==1 & q5r_73_norange==0
reg q5r_range55_size if mainsample==1 & q5r_55_norange==0
 
reg q6r_range82_size if mainsample==1 & q6r_82_norange==0
reg q6r_range73_size if mainsample==1 & q6r_73_norange==0
reg q6r_range55_size if mainsample==1 & q6r_55_norange==0

reg q7r_range82_size if mainsample==1 & q7r_82_norange==0
reg q7r_range73_size if mainsample==1 & q7r_73_norange==0
reg q7r_range55_size if mainsample==1 & q7r_55_norange==0
 
** top and bottom

reg q5r_range82_max_DollAv if mainsample==1 & q5r_82_norange==0
reg q5r_range82_min_DollAv if mainsample==1 & q5r_82_norange==0

reg q5r_range73_max_DollAv if mainsample==1 & q5r_73_norange==0
reg q5r_range73_min_DollAv if mainsample==1 & q5r_73_norange==0

reg q5r_range55_max_DollAv if mainsample==1 & q5r_55_norange==0
reg q5r_range55_min_DollAv if mainsample==1 & q5r_55_norange==0

reg q6r_range82_max_DollAv if mainsample==1 & q6r_82_norange==0
reg q6r_range82_min_DollAv if mainsample==1 & q6r_82_norange==0

reg q6r_range73_max_DollAv if mainsample==1 & q6r_73_norange==0
reg q6r_range73_min_DollAv if mainsample==1 & q6r_73_norange==0

reg q6r_range55_max_DollAv if mainsample==1 & q6r_55_norange==0
reg q6r_range55_min_DollAv if mainsample==1 & q6r_55_norange==0

reg q7r_range82_max_DollAv if mainsample==1 & q7r_82_norange==0
reg q7r_range82_min_DollAv if mainsample==1 & q7r_82_norange==0

reg q7r_range73_max_DollAv if mainsample==1 & q7r_73_norange==0
reg q7r_range73_min_DollAv if mainsample==1 & q7r_73_norange==0

reg q7r_range55_max_DollAv if mainsample==1 & q7r_55_norange==0
reg q7r_range55_min_DollAv if mainsample==1 & q7r_55_norange==0


** number of rows

gen z5xx = q5r_82max - q5r_82min
reg z5xx if mainsamp==1 & q5r_82_norange==0 
sum z5xx if mainsamp==1 & q5r_82_norange==0 , detail

gen z6xx = q6r_82max - q6r_82min
reg z6xx if mainsamp==1 & q6r_82_norange==0
sum z6xx if mainsamp==1 & q6r_82_norange==0 , detail
 
gen z7xx = q7r_82max - q7r_82min
reg z7xx if mainsamp==1 & q7r_82_norange==0
sum z7xx if mainsamp==1 & q7r_82_norange==0 , detail
 
gen z5xxx = q5r_73max - q5r_73min
reg z5xxx if mainsamp==1 & q5r_73_norange==0 
sum z5xxx if mainsamp==1 & q5r_73_norange==0  , detail
 
gen z6xxx = q6r_73max - q6r_73min
reg z6xxx if mainsamp==1 & q6r_73_norange==0 
sum z6xxx if mainsamp==1 & q6r_73_norange==0  , detail
 
gen z7xxx = q7r_73max - q7r_73min 
reg z7xxx if mainsamp==1 & q7r_73_norange==0 
sum z7xxx if mainsamp==1 & q7r_73_norange==0  , detail
 
gen z5xxxx = q5r_55max - q5r_55min
reg z5xxxx if mainsamp==1 & q5r_55_norange==0 
sum z5xxxx if mainsamp==1 & q5r_55_norange==0 , detail 
 
gen z6xxxx = q6r_55max - q6r_55min
reg z6xxxx if mainsamp==1 & q6r_55_norange==0 
sum z6xxxx if mainsamp==1 & q6r_55_norange==0  , detail 
 
gen z7xxxx = q7r_55max - q7r_55min
reg z7xxxx if mainsamp==1 & q7r_55_norange==0 
sum z7xxxx if mainsamp==1 & q7r_55_norange==0  , detail 



******************************************
** APPENDIX: Histograms of q-measures  ***
******************************************

histogram tempq5r if mainsample==1 & tempq5r!=0, bin(20) frac
histogram tempq6r if mainsample==1 & tempq6r!=0, bin(20) frac
histogram tempq7r if mainsample==1 & tempq7r!=0, bin(20) frac



***********************************************************
*** BEHAVIOR OF SUBJECTS WHO ARE MONOTONE AND NO RANGES ***
***********************************************************

replace q6_swDollAv = 54            if choiceq623==1
replace q6r_range91_min_DollAv = 54 if choiceq6r23==1 

** people who do not have ranges are CONSISTENT
pwcorr q5_swDollAv q5r_range91_min_DollAv if q5r_91_norange==1 & mainsampl==1 & q5_nonMonotone==0, sig
pwcorr q6_swDollAv q6r_range91_min_DollAv if q6r_91_norange==1 & mainsampl==1 & q6_nonMonotone==0, sig
pwcorr q7_swDollAv q7r_range91_min_DollAv if q7r_91_norange==1 & mainsampl==1 & q7_nonMonotone==0, sig


gen q5_diff = q5_swDollAv - q5r_range91_min_DollAv if q5r_91_norange==1 & mainsampl==1 & q5_nonMonotone==0
gen q6_diff = q6_swDollAv - q6r_range91_min_DollAv if q6r_91_norange==1 & mainsampl==1 & q6_nonMonotone==0
gen q7_diff = q7_swDollAv - q7r_range91_min_DollAv if q7r_91_norange==1 & mainsampl==1 & q7_nonMonotone==0

** this figure is in the Appendix
twoway (kdensity q5_diff if q5r_91_norange==1 & mainsampl==1 & q5_nonMonotone==0, color(blue))  (kdensity q6_diff if q6r_91_norange==1 & mainsampl==1 & q6_nonMonotone==0, color(red)) (kdensity q7_diff if q7r_91_norange==1 & mainsampl==1 & q7_nonMonotone==0, color(black)) 

reg   q5_diff if q5r_91_norange==1 & mainsampl==1 & q5_nonMonotone==0
test _cons=0

reg   q6_diff if q6r_91_norange==1 & mainsampl==1 & q6_nonMonotone==0
test _cons=0

reg   q7_diff if q7r_91_norange==1 & mainsampl==1 & q7_nonMonotone==0
test _cons=0

reg   q7_diff if q7r_91_norange==1 & mainsampl==1 & q7_nonMonotone==0 & q7_diff<=5
test _cons=0

** parameteric tests
ttest q5_diff = 0  if q5r_91_norange==1 & mainsampl==1 & q5_nonMonotone==0  
ttest q6_diff = 0  if q6r_91_norange==1 & mainsampl==1 & q6_nonMonotone==0  
ttest q7_diff = 0  if q7r_91_norange==1 & mainsampl==1 & q7_nonMonotone==0  
ttest q7_diff = 0  if q7r_91_norange==1 & mainsampl==1 & q7_nonMonotone==0 & q7_diff<=5 

** non-parameteric tests
signrank q5_swDollAv = q5r_range91_min_DollAv if q5r_91_norange==1 & mainsampl==1 & q5_nonMonotone==0
signrank q6_swDollAv = q6r_range91_min_DollAv if q6r_91_norange==1 & mainsampl==1 & q6_nonMonotone==0
signrank q7_swDollAv = q7r_range91_min_DollAv if q7r_91_norange==1 & mainsampl==1 & q7_nonMonotone==0

** are these people risk-averse? 
sum q5_swDollAv if q5r_91_norange==1 & mainsampl==1 & q5_nonMonotone==0
sum q6_swDollAv if q6r_91_norange==1 & mainsampl==1 & q6_nonMonotone==0
sum q7_swDollAv if q7r_91_norange==1 & mainsampl==1 & q7_nonMonotone==0

twoway histogram q5_swDollAv if q5r_91_norange==1 & mainsampl==1 & q5_nonMonotone==0, frac bin(25) color(blue) || kdensity q5_swDollAv if q5r_91_norange==1 & mainsampl==1 & q5_nonMonotone==0, color(black) 
twoway histogram q6_swDollAv if q6r_91_norange==1 & mainsampl==1 & q6_nonMonotone==0, frac bin(25) color(blue) || kdensity q6_swDollAv if q6r_91_norange==1 & mainsampl==1 & q6_nonMonotone==0, color(black)  
twoway histogram q7_swDollAv if q7r_91_norange==1 & mainsampl==1 & q7_nonMonotone==0, frac bin(25) color(blue) || kdensity q7_swDollAv if q7r_91_norange==1 & mainsampl==1 & q7_nonMonotone==0, color(black) 

*************************************************************
*** BEHAVIOR OF SUBJECTS WHO ARE MONOTONE AND HAVE RANGES ***
*************************************************************


** there are a few subjects that never switched from the left column to the right one **
** they are not included in the analysis below **

gen q5_forcedInRange91 = (q5_swDollAv<=q5r_range91_max_DollAv & q5_swDollAv>=q5r_range91_min_DollAv)
gen q5_forcedInRange64 = (q5_swDollAv<=q5r_range64_max_DollAv & q5_swDollAv>=q5r_range64_min_DollAv)
gen q6_forcedInRange91 = (q6_swDollAv<=q6r_range91_max_DollAv & q6_swDollAv>=q6r_range91_min_DollAv)
gen q6_forcedInRange64 = (q6_swDollAv<=q6r_range64_max_DollAv & q6_swDollAv>=q6r_range64_min_DollAv)
gen q7_forcedInRange91 = (q7_swDollAv<=q7r_range91_max_DollAv & q7_swDollAv>=q7r_range91_min_DollAv)
gen q7_forcedInRange64 = (q7_swDollAv<=q7r_range64_max_DollAv & q7_swDollAv>=q7r_range64_min_DollAv)


tab q5_forcedInRange91 if mainsample==1 & q5_nonMonotone==0 & q5r_91_norange==0
tab q5_forcedInRange64 if mainsample==1 & q5_nonMonotone==0 & q5r_64_norange==0

tab q6_forcedInRange91 if mainsample==1 & q6_nonMonotone==0 & q6r_91_norange==0
tab q6_forcedInRange64 if mainsample==1 & q6_nonMonotone==0 & q6r_64_norange==0

tab q7_forcedInRange91 if mainsample==1 & q7_nonMonotone==0 & q7r_91_norange==0
tab q7_forcedInRange64 if mainsample==1 & q7_nonMonotone==0 & q7r_64_norange==0


gen lambdaQ5_91 = (q5_swDollAv - q5r_range91_min_DollAv)/(q5r_range91_max_DollAv-q5r_range91_min_DollAv) if q5r_91_norange==0
gen lambdaQ6_91 = (q6_swDollAv - q6r_range91_min_DollAv)/(q6r_range91_max_DollAv-q6r_range91_min_DollAv) if q6r_91_norange==0
gen lambdaQ7_91 = (q7_swDollAv - q7r_range91_min_DollAv)/(q7r_range91_max_DollAv-q7r_range91_min_DollAv) if q7r_91_norange==0

gen lambdaQ5_64 = (q5_swDollAv - q5r_range64_min_DollAv)/(q5r_range64_max_DollAv-q5r_range64_min_DollAv) if q5r_64_norange==0
gen lambdaQ6_64 = (q6_swDollAv - q6r_range64_min_DollAv)/(q6r_range64_max_DollAv-q6r_range64_min_DollAv) if q6r_64_norange==0
gen lambdaQ7_64 = (q7_swDollAv - q7r_range64_min_DollAv)/(q7r_range64_max_DollAv-q7r_range64_min_DollAv) if q7r_64_norange==0

gen     lambda_av_91 = lambdaQ5_91                               if lambdaQ5_91!=. & lambdaQ6_91==. & lambdaQ7_91==.  
replace lambda_av_91 = 1-lambdaQ6_91                             if lambdaQ5_91==. & lambdaQ6_91!=. & lambdaQ7_91==. 
replace lambda_av_91 = lambdaQ7_91                               if lambdaQ5_91==. & lambdaQ6_91==. & lambdaQ7_91!=.   
replace lambda_av_91 = (lambdaQ5_91+1-lambdaQ6_91)/2             if lambdaQ5_91!=. & lambdaQ6_91!=. & lambdaQ7_91==. 
replace lambda_av_91 = (lambdaQ5_91+lambdaQ7_91)/2               if lambdaQ5_91!=. & lambdaQ6_91==. & lambdaQ7_91!=. 
replace lambda_av_91 = (lambdaQ7_91+1-lambdaQ6_91)/2             if lambdaQ5_91==. & lambdaQ6_91!=. & lambdaQ7_91!=. 
replace lambda_av_91 = (lambdaQ5_91+1-lambdaQ6_91+lambdaQ7_91)/3 if lambdaQ5_91!=. & lambdaQ6_91!=. & lambdaQ7_91!=.     

gen     lambda_av_64 = lambdaQ5_64                               if lambdaQ5_64!=. & lambdaQ6_64==. & lambdaQ7_64==.  
replace lambda_av_64 = 1-lambdaQ6_64                             if lambdaQ5_64==. & lambdaQ6_64!=. & lambdaQ7_64==. 
replace lambda_av_64 = lambdaQ7_64                               if lambdaQ5_64==. & lambdaQ6_64==. & lambdaQ7_64!=.   
replace lambda_av_64 = (lambdaQ5_64+1-lambdaQ6_64)/2             if lambdaQ5_64!=. & lambdaQ6_64!=. & lambdaQ7_64==. 
replace lambda_av_64 = (lambdaQ5_64+lambdaQ7_64)/2               if lambdaQ5_64!=. & lambdaQ6_64==. & lambdaQ7_64!=. 
replace lambda_av_64 = (lambdaQ7_64+1-lambdaQ6_64)/2             if lambdaQ5_64==. & lambdaQ6_64!=. & lambdaQ7_64!=. 
replace lambda_av_64 = (lambdaQ5_64+1-lambdaQ6_64+lambdaQ7_64)/3 if lambdaQ5_64!=. & lambdaQ6_64!=. & lambdaQ7_64!=.  

count if lambda_av_91!=.
count if lambda_av_91!=. & lambda_av_91>=-2 & lambda_av_91<=2
count if lambda_av_91!=. & lambda_av_91>=-3 & lambda_av_91<=3

count if lambda_av_64!=.
count if lambda_av_64!=. & lambda_av_64>=-2 & lambda_av_64<=2
count if lambda_av_64!=. & lambda_av_64>=-3 & lambda_av_64<=3

** Figure 1 in the text
twoway histogram lambda_av_91 if mainsample==1 & lambda_av_91>=-3 & lambda_av_91<=3, bin(20) || kdensity lambda_av_91 if mainsample==1 & lambda_av_91>=-3 & lambda_av_91<=3
twoway histogram lambda_av_64 if mainsample==1 & lambda_av_64>=-3 & lambda_av_64<=3, bin(20) || kdensity lambda_av_64 if mainsample==1 & lambda_av_64>=-3 & lambda_av_64<=3
 
*pwcorr lambda_av_91 q5_swDollAv q6_swDollAv q7_swDollAv allais_comb if mainsample==1 & lambda_av_91>=-3 & lambda_av_91<=3, sig
*pwcorr lambda_av_64 q5_swDollAv q6_swDollAv q7_swDollAv allais_comb if mainsample==1 & lambda_av_64>=-3 & lambda_av_64<=3, sig


** Figures in the appendix
twoway histogram lambdaQ5_91 if mainsample==1 & lambdaQ5_91>=-3 & lambdaQ5_91<=3,  bin(20) || kdensity lambdaQ5_91 if mainsample==1 & lambdaQ5_91>=-3 & lambdaQ5_91<=3
twoway histogram lambdaQ5_64 if mainsample==1 & lambdaQ5_64>=-3 & lambdaQ5_64<=3,  bin(20) || kdensity lambdaQ5_64 if mainsample==1 & lambdaQ5_64>=-3 & lambdaQ5_64<=3
twoway histogram lambdaQ6_91 if mainsample==1 & lambdaQ6_91>=-3 & lambdaQ6_91<=3,  bin(20) || kdensity lambdaQ6_91 if mainsample==1 & lambdaQ6_91>=-3 & lambdaQ6_91<=3
twoway histogram lambdaQ6_64 if mainsample==1 & lambdaQ6_64>=-3 & lambdaQ6_64<=3,  bin(20) || kdensity lambdaQ6_64 if mainsample==1 & lambdaQ6_64>=-3 & lambdaQ6_64<=3
twoway histogram lambdaQ7_91 if mainsample==1 & lambdaQ7_91>=-3 & lambdaQ7_91<=3,  bin(20) || kdensity lambdaQ7_91 if mainsample==1 & lambdaQ7_91>=-3 & lambdaQ7_91<=3
twoway histogram lambdaQ7_64 if mainsample==1 & lambdaQ7_64>=-3 & lambdaQ7_64<=3,  bin(20) || kdensity lambdaQ7_64 if mainsample==1 & lambdaQ7_64>=-3 & lambdaQ7_64<=3

** numbers in the text


count if lambdaQ5_91>=0 & lambdaQ5_91<=1 & mainsampl==1 & lambdaQ5_91!=.
count if mainsampl==1 & lambdaQ5_91!=.

count if lambdaQ6_91>=0 & lambdaQ6_91<=1 & mainsampl==1 & lambdaQ6_91!=.
count if mainsampl==1 & lambdaQ6_91!=.

count if lambdaQ7_91>=0 & lambdaQ7_91<=1 & mainsampl==1 & lambdaQ7_91!=.
count if mainsampl==1 & lambdaQ7_91!=.

count if lambdaQ5_64>=0 & lambdaQ5_64<=1 & mainsampl==1 & lambdaQ5_64!=.
count if mainsampl==1 & lambdaQ5_64!=.

count if lambdaQ6_64>=0 & lambdaQ6_64<=1 & mainsampl==1 & lambdaQ6_64!=.
count if mainsampl==1 & lambdaQ6_64!=.

count if lambdaQ7_64>=0 & lambdaQ7_64<=1 & mainsampl==1 & lambdaQ7_64!=.
count if mainsampl==1 & lambdaQ7_64!=.


count if lambda_av_91>=-0.5 & lambda_av_91<=0.25
count if lambda_av_91>0.25 & lambda_av_91<=0.75
count if lambda_av_91>0.75 & lambda_av_91<=1.5

count if lambda_av_64>=-0.5 & lambda_av_64<=0.25
count if lambda_av_64>0.25  & lambda_av_64<=0.75
count if lambda_av_64>0.75  & lambda_av_64<=1.5
 


**************************************
*** TABLE 3: BIG CORRELATION TABLE ***
**************************************

** for people that never switched in questions 1 or 2 (always chose left option), we use the most conservative measure of continuous allais 
** and assign to them q1_swDollAv = q2_swDollAv = max(range) = 27
** similarly, for people that never switched in questions 3 or 4 (always chose left option), we assign q3_swDollAv = q4_swDollAv = max(range) = 25
 
replace q1_swDollAv = 27 if choiceq117==1
replace q2_swDollAv = 27 if choiceq217==1
replace q3_swDollAv = 25 if choiceq317==1
replace q4_swDollAv = 25 if choiceq417==1



** Define ALLAIS and ANTI-ALLAIS measures

gen allais1 =  q1_swDollAv - q2_swDollAv if q1_nonMonotone==0 & q2_nonMonotone==0
gen allais2 =  q3_swDollAv - q4_swDollAv if q3_nonMonotone==0 & q4_nonMonotone==0

gen allais_comb = allais1/16 + allais2/14 

gen z = (allais_comb<=0.1 & allais_comb>=-0.1)

tab allais_comb if mainsample==1 & q1_nonMonotone==0 & q2_nonMonotone==0 & q3_nonMonotone==0 & q4_nonMonotone==0
tab z           if mainsample==1 & q1_nonMonotone==0 & q2_nonMonotone==0 & q3_nonMonotone==0 & q4_nonMonotone==0
tab allais_comb if mainsample==1 & z!=1 & q1_nonMonotone==0 & q2_nonMonotone==0 & q3_nonMonotone==0 & q4_nonMonotone==0

gen     allais = 1 if (allais1>0.5   | allais2>0.5) & allais1!=. & allais2!=.
replace allais = 0 if allais==. & allais1!=. & allais2!=.

gen     antiallais = 1 if (allais1<-0.5  | allais2<-0.5) & allais1!=. & allais2!=.
replace antiallais = 0 if antiallais==. & allais1!=. & allais2!=.

gen allaisneutral = (allais==0 & antiallais==0)
 
gen     monotoneQ1Q4 = 1 if q1_nonMonotone==0 & q3_nonMonotone==0 & q2_nonMonotone==0 & q4_nonMonotone==0
replace monotoneQ1Q4 = 0 if q1_nonMonotone==1 | q3_nonMonotone==1 | q2_nonMonotone==1 | q4_nonMonotone==1
tab     monotoneQ1Q4     if mainsam==1

gen     nonMonotone = 1 if q1_nonMonotone==1 | q2_nonMonotone==1 | q3_nonMonotone==1 | q4_nonMonotone==1 | q5_nonMonotone==1 | q6_nonMonotone==1 | q7_nonMonotone==1
replace nonMonotone = 0 if q1_nonMonotone==0 & q2_nonMonotone==0 & q3_nonMonotone==0 & q4_nonMonotone==0 & q5_nonMonotone==0 & q6_nonMonotone==0 & q7_nonMonotone==0

gen     nonMonotone2 = 1 if  q5_nonMonotone==1 | q6_nonMonotone==1 | q7_nonMonotone==1
replace nonMonotone2 = 0 if  q5_nonMonotone==0 & q6_nonMonotone==0 & q7_nonMonotone==0

tab q5_nonMonotone if mainsample==1
tab q6_nonMonotone if mainsample==1
tab q7_nonMonotone if mainsample==1
tab nonMonotone2   if mainsample==1

pwcorr noranges91 range91NumQ range91size_norm1 range91size_norm2 allais antiallais allais_comb if mainsample==1 & monotoneQ1Q4==1, sig
pwcorr noranges64 range64NumQ range64size_norm1 range64size_norm2 allais antiallais allais_comb if mainsample==1 & monotoneQ1Q4==1, sig

pwcorr noranges91 range91NumQ range91size_norm1 range91size_norm2 nonMonotone nonMonotone2 if mainsample==1, sig
pwcorr noranges64 range64NumQ range64size_norm1 range64size_norm2 nonMonotone nonMonotone2 if mainsample==1, sig

** in the paper 
pwcorr noranges91 range91NumQ   range91size_norm2 q5_swDollAv q6_swDollAv q7_swDollAv if mainsample==1, sig bonferroni
pwcorr noranges64 range64NumQ   range64size_norm2 q5_swDollAv q6_swDollAv q7_swDollAv if mainsample==1, sig bonferroni
pwcorr noranges91 range91NumQ   range91size_norm2 allais_comb if mainsample==1, sig  bonferroni
pwcorr noranges64 range64NumQ   range64size_norm2 allais_comb if mainsample==1, sig  bonferroni
pwcorr noranges91 range91NumQ   range91size_norm2 nonMonotone if mainsample==1, sig  bonferroni
pwcorr noranges64 range64NumQ   range64size_norm2 nonMonotone if mainsample==1, sig  bonferroni


** average q-measure
pwcorr  q_average q5_swDollAv q6_swDollAv q7_swDollAv if mainsample==1, sig  bonferroni
pwcorr  q_average allais_comb if mainsample==1, sig  bonferroni
pwcorr  q_average nonMonotone if mainsample==1, sig  bonferroni


** correlation with investment task (Gneezy & Potters)
pwcorr noranges91 range91NumQ   range91size_norm2 risk1 risk2 if mainsample==1, sig  bonferroni
pwcorr noranges64 range64NumQ   range64size_norm2 risk1 risk2 if mainsample==1, sig  bonferroni
pwcorr q_average  risk1 risk2 if mainsample==1, sig  bonferroni
 
pwcorr   risk1 risk2 q5_swDollAv  q6_swDollAv q7_swDollAv nonMonotone allais_comb  if mainsample==1, sig  bonferroni


** in the appendix (table A.2)
pwcorr   range91size_norm1 q5_swDollAv q6_swDollAv q7_swDollAv if mainsample==1, sig
pwcorr   range64size_norm1 q5_swDollAv q6_swDollAv q7_swDollAv if mainsample==1, sig
pwcorr   range91size_norm1 nonMonotone   if mainsample==1, sig
pwcorr   range91size_norm1 allais_comb   if mainsample==1, sig
pwcorr   range64size_norm1 nonMonotone   if mainsample==1, sig
pwcorr   range64size_norm1 allais_comb   if mainsample==1, sig

pwcorr   range91size_norm1 range64size_norm1 risk1 risk2   if mainsample==1, sig


 
*******************************************
** RANGES AND INDIVIDUAL CHARACTERISTICS **
*******************************************

** Creating individual characteristics from control questions **

* q60, q61, q62 - standard Raven matrices
* q67, q68, q69 - rotation Raven matrices

* q72 - how many of the six Raven puzzles you solved correctly?
* q73 - your rank among 100 people in US: 1 = most correct, 100 = least correct

* q70 - year in which wired telephone was invented
* q57 - how confident you are in your answer
* q58 - probability that your answer is correct

* q74 - CRT bat and ball
* q75 - CRT machines and widgets
* q76 - CRT lake and lilies

* questionnaire - did you ever chose numbers different from 1 or 10, why?

gen raven1_cor = (q60=="D")
gen raven2_cor = (q61=="E")
gen raven3_cor = (q62=="C")
gen raven4_cor = (q67=="F")
gen raven5_cor = (q68=="E")
gen raven6_cor = (q69=="B")

gen raven_correct = raven1_cor + raven2_cor + raven3_cor + raven4_cor + raven5_cor + raven6_cor
tab raven_correct if mainsamp==1

gen crt1_cor = (q74==5)
gen crt2_cor = (q75==5)
gen crt3_cor = (q76==47)

gen crt_correct = crt1_cor + crt2_cor + crt3_cor
tab crt_correct

gen     iq = raven_correct/6 + crt_correct/3
gen     iq2 = raven_correct + crt_correct
 
** here is the distribution of US population (from 1000 people)

*          0 |        194       19.40       19.40
*          1 |        229       22.90       42.30
*          2 |        220       22.00       64.30
*          3 |        173       17.30       81.60
*          4 |         79        7.90       89.50
*          5 |         56        5.60       95.10
*          6 |         49        4.90      100.00

gen     raven_rank = 1  if raven_correct == 6
replace raven_rank = 6  if raven_correct == 5
replace raven_rank = 11 if raven_correct == 4
replace raven_rank = 19 if raven_correct == 3
replace raven_rank = 36 if raven_correct == 2
replace raven_rank = 58 if raven_correct == 1
replace raven_rank = 81 if raven_correct == 0

gen raven_overest   = q72 - raven_correct  
gen raven_overplace = q73 - raven_rank

 
pwcorr iq iq2 raven_correct crt_correct if mainsampl==1, sig

** in the appendix - Table A.3
pwcorr noranges91 range91NumQ range91size_norm2 crt_correct raven_correct iq iq2 if mainsample==1, sig
pwcorr noranges64 range64NumQ range64size_norm2 crt_correct raven_correct iq iq2 if mainsample==1, sig

gen     phone = q70 - 1876 if q70>=1876 
replace phone = -q70 + 1876 if q70<1876 

gen phone2 = phone*phone
gen phone3 = phone*phone2
gen phone4 = phone*phone3


gen     confidence1 = 0 if q57=="No confidence at all"
replace confidence1 = 1 if q57=="Not bery confident"
replace confidence1 = 2 if q57=="Somewhat confident"
replace confidence1 = 3 if q57=="Somewhat unconfident"

gen confidence2 = q58

reg confidence1 phone phone2 phone3 phone4 if mainsample==1
predict confidence1_pr
gen overconfidence1 = confidence1 - confidence1_pr

reg confidence2 phone phone2 phone3 phone4 if mainsample==1
predict confidence2_pr
gen overconfidence2 = confidence2 - confidence2_pr

pwcorr noranges91 range91NumQ range91size_norm2 raven_overes raven_overpl overconfidence1 overconfidence2 if mains==1, sig
pwcorr noranges64 range64NumQ range64size_norm2 raven_overes raven_overpl overconfidence1 overconfidence2 if mains==1, sig

pwcorr lambda_av_91 iq raven_corr crt_corr raven_overes raven_overpl overconfidence1 overconfidence2 if mainsa==1 & lambda_av_91>=-3 & lambda_av_91<=3, sig
pwcorr lambda_av_64 iq raven_corr crt_corr raven_overes raven_overpl overconfidence1 overconfidence2 if mainsa==1 & lambda_av_64>=-3 & lambda_av_64<=3, sig


** Define risk attitude measures based on each question separately: Q1 - Q4 and investment tasks

gen     riskaverse_q1 = 1 if q1_swDollAv> 20.25 & q1_swDollAv!=. & q1_nonMonotone==0
replace riskaverse_q1 = 0 if q1_swDollAv<=20.25 & q1_swDollAv!=. & q1_nonMonotone==0
replace riskaverse_q1 = 1 if q1_swDollAv==.     & choiceq117==1  & q1_nonMonotone==0

gen     riskaverse_q2 = 1 if q2_swDollAv> 20.25 & q2_swDollAv!=. & q2_nonMonotone==0
replace riskaverse_q2 = 0 if q2_swDollAv<=20.25 & q2_swDollAv!=. & q2_nonMonotone==0
replace riskaverse_q2 = 1 if q2_swDollAv==.     & choiceq217==1  & q2_nonMonotone==0

gen     riskaverse_q3 = 1 if q3_swDollAv> 18.25 & q3_swDollAv!=. & q3_nonMonotone==0
replace riskaverse_q3 = 0 if q3_swDollAv<=18.25 & q3_swDollAv!=. & q3_nonMonotone==0
replace riskaverse_q3 = 1 if q3_swDollAv==.     & choiceq317==1  & q3_nonMonotone==0

gen     riskaverse_q4 = 1 if q4_swDollAv> 18.25 & q4_swDollAv!=. & q4_nonMonotone==0
replace riskaverse_q4 = 0 if q4_swDollAv<=18.25 & q4_swDollAv!=. & q4_nonMonotone==0
replace riskaverse_q4 = 1 if q4_swDollAv==.     & choiceq417==1  & q4_nonMonotone==0

gen     riskaverse_q5 = 1 if q5_swDollAv < 9.75 & q5_swDollAv!=. & q5_nonMonotone==0
replace riskaverse_q5 = 0 if q5_swDollAv >=9.75 & q5_swDollAv!=. & q5_nonMonotone==0

gen     riskaverse_q6 = 1 if q6_swDollAv> 36.25 & q6_swDollAv!=. & q6_nonMonotone==0
replace riskaverse_q6 = 0 if q6_swDollAv<=36.25 & q6_swDollAv!=. & q6_nonMonotone==0

gen     riskaverse_q7 = 1 if q7_swDollAv <17.75 & q7_swDollAv!=. & q7_nonMonotone==0
replace riskaverse_q7 = 0 if q7_swDollAv>=17.75 & q7_swDollAv!=. & q7_nonMonotone==0

 

gen     riskaverse_risk1 = (risk1<100 & risk1>0)
gen     riskaverse_risk2 = (risk2<100 & risk2>0)

gen     ra_type1 = 1 if (riskaverse_q1==1 | riskaverse_q3==1) & q1_nonMonotone==0 & q3_nonMonotone==0
replace ra_type1 = 0 if riskaverse_q1==0 & riskaverse_q3==0 & q1_nonMonotone==0 & q3_nonMonotone==0

gen     ra_type2 = 1 if (riskaverse_q2==1 | riskaverse_q4==1) & q2_nonMonotone==0 & q4_nonMonotone==0
replace ra_type2 = 0 if riskaverse_q2==0 & riskaverse_q4==0 & q2_nonMonotone==0 & q4_nonMonotone==0

gen     ra_type3 = 1 if (riskaverse_risk1==1 | riskaverse_risk2==1) 
replace ra_type3 = 0 if riskaverse_risk1==0 & riskaverse_risk2==0 
 
tab ra_type1 if mainsample==1 & q1_nonMonotone==0 & q3_nonMonotone==0 & q2_nonMonotone==0 & q4_nonMonotone==0
tab ra_type2 if mainsample==1 & q2_nonMonotone==0 & q4_nonMonotone==0 & q1_nonMonotone==0 & q3_nonMonotone==0 
tab ra_type3 if mainsample==1 & q1_nonMonotone==0 & q3_nonMonotone==0 & q2_nonMonotone==0 & q4_nonMonotone==0

gen risk_type1 = q1_swDollAv/16 + q3_swDollAv/14
gen risk_type2 = q2_swDollAv/16 + q4_swDollAv/14



************************
*** INDIVIDUAL TYPES ***
************************

gen     nonMonMPL = 1 if q1_nonMonotone==1 | q2_nonMonotone==1 | q3_nonMonotone==1 | q4_nonMonotone==1 | q5_nonMonotone==1 | q6_nonMonotone==1 | q7_nonMonotone==1
replace nonMonMPL = 0 if q1_nonMonotone==0 & q2_nonMonotone==0 & q3_nonMonotone==0 & q4_nonMonotone==0 & q5_nonMonotone==0 & q6_nonMonotone==0 & q7_nonMonotone==0 
tab nonMonMPL if mainsample==1

count if nonMonMPL==0 & mainsample==1 & noranges91==0
count if nonMonMPL==0 & mainsample==1 & noranges91==1
count if nonMonMPL==1 & mainsample==1 & noranges91==0
count if nonMonMPL==1 & mainsample==1 & noranges91==1



*************************************************
****     ANSWERS TO THE QUESTIONNAIRE        ****
*************************************************

** appendix - table A.4


tab chat  if nonMonMPL==0 & mainsample==1 & noranges91==0
tab chat  if nonMonMPL==0 & mainsample==1 & noranges91==1
tab chat  if nonMonMPL==1 & mainsample==1 & noranges91==0
tab chat  if nonMonMPL==1 & mainsample==1 & noranges91==1


** appendix - table A.5
gen chatyes = (chat!=0)
pwcorr chatyes noranges91 noranges64 q_av range91size_norm2 range64size_norm2 if mainsample==1 & chat!=., sig

 
****************************************************************
*** TABLE B.7: SUMMARY STATISTICS ABOUT RANGES ORDER EFFECTS ***
****************************************************************

tab q5r_91_norange if mainsample==1 & order==0
tab q6r_91_norange if mainsample==1 & order==0
tab q7r_91_norange if mainsample==1 & order==0

tab q5r_64_norange if mainsample==1 & order==0
tab q6r_64_norange if mainsample==1 & order==0
tab q7r_64_norange if mainsample==1 & order==0


tab q5r_91_norange if mainsample==1 & order==1
tab q6r_91_norange if mainsample==1 & order==1
tab q7r_91_norange if mainsample==1 & order==1

tab q5r_64_norange if mainsample==1 & order==1
tab q6r_64_norange if mainsample==1 & order==1
tab q7r_64_norange if mainsample==1 & order==1

reg q5r_range91_size if mainsample==1 & q5r_91_norange==0 & order==0
reg q5r_range64_size if mainsample==1 & q5r_64_norange==0 & order==0
reg q5r_range91_size if mainsample==1 & q5r_91_norange==0 & order==1
reg q5r_range64_size if mainsample==1 & q5r_64_norange==0 & order==1

reg q6r_range91_size if mainsample==1 & q6r_91_norange==0  & order==0
reg q6r_range64_size if mainsample==1 & q6r_64_norange==0  & order==0
reg q6r_range91_size if mainsample==1 & q6r_91_norange==0  & order==1
reg q6r_range64_size if mainsample==1 & q6r_64_norange==0  & order==1
 

reg q7r_range91_size if mainsample==1 & q7r_91_norange==0 & order==0
reg q7r_range64_size if mainsample==1 & q7r_64_norange==0 & order==0
reg q7r_range91_size if mainsample==1 & q7r_91_norange==0 & order==1
reg q7r_range64_size if mainsample==1 & q7r_64_norange==0 & order==1


reg q5r_range91_max_DollAv if mainsample==1 & q5r_91_norange==0 & order==0
reg q5r_range91_min_DollAv if mainsample==1 & q5r_91_norange==0 & order==0
reg q5r_range64_max_DollAv if mainsample==1 & q5r_64_norange==0 & order==0
reg q5r_range64_min_DollAv if mainsample==1 & q5r_64_norange==0 & order==0

reg q5r_range91_max_DollAv if mainsample==1 & q5r_91_norange==0 & order==1
reg q5r_range91_min_DollAv if mainsample==1 & q5r_91_norange==0 & order==1
reg q5r_range64_max_DollAv if mainsample==1 & q5r_64_norange==0 & order==1
reg q5r_range64_min_DollAv if mainsample==1 & q5r_64_norange==0 & order==1


reg q6r_range91_max_DollAv if mainsample==1 & q6r_91_norange==0 & order==0
reg q6r_range91_min_DollAv if mainsample==1 & q6r_91_norange==0 & order==0
reg q6r_range64_max_DollAv if mainsample==1 & q6r_64_norange==0 & order==0
reg q6r_range64_min_DollAv if mainsample==1 & q6r_64_norange==0 & order==0

reg q6r_range91_max_DollAv if mainsample==1 & q6r_91_norange==0 & order==1
reg q6r_range91_min_DollAv if mainsample==1 & q6r_91_norange==0 & order==1
reg q6r_range64_max_DollAv if mainsample==1 & q6r_64_norange==0 & order==1
reg q6r_range64_min_DollAv if mainsample==1 & q6r_64_norange==0 & order==1


reg q7r_range91_max_DollAv if mainsample==1 & q7r_91_norange==0 & order==0
reg q7r_range91_min_DollAv if mainsample==1 & q7r_91_norange==0 & order==0
reg q7r_range64_max_DollAv if mainsample==1 & q7r_64_norange==0 & order==0
reg q7r_range64_min_DollAv if mainsample==1 & q7r_64_norange==0 & order==0

reg q7r_range91_max_DollAv if mainsample==1 & q7r_91_norange==0 & order==1
reg q7r_range91_min_DollAv if mainsample==1 & q7r_91_norange==0 & order==1
reg q7r_range64_max_DollAv if mainsample==1 & q7r_64_norange==0 & order==1
reg q7r_range64_min_DollAv if mainsample==1 & q7r_64_norange==0 & order==1

reg q5r_range91_numrows if mainsample==1 & q5r_range91_size!=0 & order==0
reg q5r_range64_numrows if mainsample==1 & q5r_range64_size!=0 & order==0

reg q6r_range91_numrows if mainsample==1 & q6r_range91_size!=0 & order==0
reg q6r_range64_numrows if mainsample==1 & q6r_range64_size!=0 & order==0

reg q7r_range91_numrows if mainsample==1 & q7r_range91_size!=0 & order==0
reg q7r_range64_numrows if mainsample==1 & q7r_range64_size!=0 & order==0


sum q5r_range91_numrows if mainsample==1 & q5r_range91_size!=0& order==0, detail
sum q5r_range64_numrows if mainsample==1 & q5r_range64_size!=0& order==0, detail

sum q6r_range91_numrows if mainsample==1 & q6r_range91_size!=0& order==0, detail
sum q6r_range64_numrows if mainsample==1 & q6r_range64_size!=0& order==0, detail

sum q7r_range91_numrows if mainsample==1 & q7r_range91_size!=0& order==0, detail
sum q7r_range64_numrows if mainsample==1 & q7r_range64_size!=0& order==0, detail


reg q5r_range91_numrows if mainsample==1 & q5r_range91_size!=0 & order==1
reg q5r_range64_numrows if mainsample==1 & q5r_range64_size!=0 & order==1

reg q6r_range91_numrows if mainsample==1 & q6r_range91_size!=0 & order==1
reg q6r_range64_numrows if mainsample==1 & q6r_range64_size!=0 & order==1

reg q7r_range91_numrows if mainsample==1 & q7r_range91_size!=0 & order==1
reg q7r_range64_numrows if mainsample==1 & q7r_range64_size!=0 & order==1


sum q5r_range91_numrows if mainsample==1 & q5r_range91_size!=0& order==1, detail
sum q5r_range64_numrows if mainsample==1 & q5r_range64_size!=0& order==1, detail

sum q6r_range91_numrows if mainsample==1 & q6r_range91_size!=0& order==1, detail
sum q6r_range64_numrows if mainsample==1 & q6r_range64_size!=0& order==1, detail

sum q7r_range91_numrows if mainsample==1 & q7r_range91_size!=0& order==1, detail
sum q7r_range64_numrows if mainsample==1 & q7r_range64_size!=0& order==1, detail

 
tab noranges91 if mainsample==1 & order==0
tab noranges64 if mainsample==1 & order==0
tab range91NumQ if mainsample==1 & order==0 & noranges91==0
tab range64NumQ if mainsample==1 & order==0 & noranges64==0


tab noranges91 if mainsample==1 & order==1
tab noranges64 if mainsample==1 & order==1
tab range91NumQ if mainsample==1 & order==1 & noranges91==0
tab range64NumQ if mainsample==1 & order==1 & noranges64==0


